#include <iostream>
using namespace std;

int main(){
	int n = 4;
	if(n==3){
		cout<<"3 1 3 7 9"<<endl;
		cout<<"5 2 4 6 8"<<endl;
	}
	else{
		cout<<'3';
		int a[10]={2,3,4,n+1,n+2,n+3,2*n+1,2*n+2,3*n+1};
		for(int i=1;i<=n*n;i++){
			int flag=0;
			for(int j=0;j<9;j++){
				if(i==a[j]) flag=1;
			}
			if(!flag) cout<<' '<<i;
		}
		cout<<endl;
		cout<<'1'<<' '<<'4'<<' '<<n+3<<' '<<2*n+2<<' '<<3*n+1<<endl;
		cout<<'5'<<' '<<'3'<<' '<<n+2<<' '<<2*n+1<<endl;
		cout<<'7'<<' '<<'2'<<' '<<n+1<<endl;
	}
	return 0;
}
